package com.highspeed.bdk.bean.entity.deploy;

import com.bianmaba.spring.data.jpa.domain.annotations.QueryCacheable;
import com.highspeed.bdk.bean.base.BaseEntity;
import com.highspeed.bdk.bean.entity.logic.LogicTopology;
import com.highspeed.bdk.bean.entity.physical.PhysicalTopology;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by chenjiabin on 2018/3/23.
 * 部署拓扑图
 */
@Entity
@DynamicUpdate(true)
@DynamicInsert(true)
@QueryCacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class DeployTopology extends BaseEntity {
    @Column(nullable = false, length = 32)
    private String no;

    @Column(nullable = false, length = 16)
    private String name;

    @Column(length = 32)
    private String modifier;

    @Column()
    private Date lastModifyTime;

    @Column(length = 255)
    private String remark;

    @Column(nullable = false)
    private Boolean enabled = true;

    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "DeployTopology_id")
    private List<AppCpuBindor> acBindors = new ArrayList<AppCpuBindor>(0);

    /**
     * 预置的逻辑拓扑图，以便将其中的应用放到界面上做为应用源，此关联断开时，需要清空应用与CPU的绑定
     */
    @ManyToOne()
    @JoinColumn(name = "LogicTopology_id")
    private LogicTopology preinstalledLogicTopology;

    @ManyToOne()
    @JoinColumn(name = "PhysicalTopology_id")
    private PhysicalTopology physicalTopology;

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public List<AppCpuBindor> getAcBindors() {
        return acBindors;
    }

    public void setAcBindors(List<AppCpuBindor> acBindors) {
        this.acBindors = acBindors;
    }

    public LogicTopology getPreinstalledLogicTopology() {
        return preinstalledLogicTopology;
    }

    public void setPreinstalledLogicTopology(LogicTopology preinstalledLogicTopology) {
        this.preinstalledLogicTopology = preinstalledLogicTopology;
    }

    public PhysicalTopology getPhysicalTopology() {
        return physicalTopology;
    }

    public void setPhysicalTopology(PhysicalTopology physicalTopology) {
        this.physicalTopology = physicalTopology;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }
}
